﻿#ifndef VPOINT_H
#define VPOINT_H

#include <QPointF>

class VPoint
{
public:
    VPoint();                   //默认构造函数
    VPoint(double x, double y); //使用特定X,Y构造
    ~VPoint();

    double length() const;    //获取长度
    double angle() const;     //获取角度
    double x() const;         //获取X轴值
    double y() const;         //获取Y轴值

    void setLength(double length);  //设定长度
    void setAngle(double angle);    //设定角度
    void setX(double x);        //设定X轴值
    void setY(double y);        //设定Y轴值

    VPoint & operator += (const VPoint &point); //加上另外一个VPoint的值
    VPoint & operator -= (const VPoint &point); //减去另外一个VPoint的值
    VPoint & operator  = (double value);        //将一个长度值赋予VPoint(相当于setLength(x))
    VPoint & operator += (double value);        //将VPoint长度加上特定值
    VPoint & operator -= (double value);        //将VPoint长度减去特定值
    VPoint & operator *= (double value);        //将VPoint长度乘特定值
    VPoint & operator /= (double value);        //将VPoint长度除特定值

    friend bool operator != (const VPoint &p1, const VPoint &p2);   //对比两个VPoint是否相异
    friend bool operator == (const VPoint &p1, const VPoint &p2);   //对比两个VPoint是否相同
    friend const VPoint operator + (const VPoint &p1, const VPoint &p2);//将两个VPoint相加后返回值
    friend const VPoint operator - (const VPoint &p1, const VPoint &p2);//将两个VPoint相减后返回值


    //Qt专用
    VPoint(const QPointF &point);           //使用QPointF构造
    void fromQPointF(const QPointF &point); //使用QPointF改变数值
    QPointF toQPointF() const;              //输出QPointF值

private:
    double X;
    double Y;
};

#endif // VPOINT_H
